import { Controller, Get, Post, Body, Query, Param } from '@nestjs/common';
import { GpuService } from './gpu.service';

// import { CreateGpuDto } from './dto/create-gpu.dto';
// import { UpdateGpuDto } from './dto/update-gpu.dto';
import type { GpuType } from '../type/gpu_type';

@Controller('gpu')
export class GpuController {
  constructor(private readonly gpuService: GpuService) {}

  //添加显卡芯片数据
  @Post('/code')
  async createGpuCode(@Body() body: any) {
    const { code_name, manufacturers } = body;
    return this.gpuService.createGpuCode(code_name, manufacturers);
  }

  //查询显卡芯片数据
  @Get('/code')
  async findGpuCodeByManufacturers(@Query() query: any) {
    const { manufacturers } = query;
    return this.gpuService.findGpuCodeByManufacturers(manufacturers);
  }

  @Post('/uploads')
  async random() {
    return;
  }

  //上传显卡信息
  @Post('/gpuInfo')
  async createGpuInfo(@Body() body: GpuType) {
    return this.gpuService.createGpuInfo(body);
  }

  @Get('/gpuInfo')
  async getGpuInfo(@Query() query: any) {
    return this.gpuService.getGpuInfo(query);
  }

  @Get('/gpuInfo/:id')
  async getGpuInfoById(@Param('id') id: string) {
    return this.gpuService.getGpuInfoById(id);
  }

  //更新显卡信息
  @Post('/gpuInfo/:id')
  async updateGpuInfo(@Param('id') id: string, @Body() body: any) {
    return this.gpuService.updateGpuInfo(id, body);
  }

  //删除显卡信息
  @Post('/gpuInfo/delete/:id')
  async deleteGpuInfo(@Param('id') id: string) {
    return this.gpuService.deleteGpuInfo(id);
  }

  //请求所有显卡信息
  @Get('/total')
  async getTotalGpuInfo() {
    return this.gpuService.getTotalGpuInfo();
  }
}
